from django.db import models

# Budget Classes
class Category(models.Model):
    name = models.CharField(max_length=200)
    type = models.DecimalField(max_digits=20, decimal_places=0)

    def __unicode__(self):
        return self.name

class Frequency(models.Model):
    name = models.CharField(max_length=200)
    scalar = models.DecimalField(max_digits=20, decimal_places=4)

    def __unicode__(self):
        return self.name

class BudgetItem(models.Model):
    name = models.CharField(max_length=200)
    category = models.ForeignKey(Category)
    frequency = models.ForeignKey(Frequency)
    amount = models.DecimalField(max_digits=20, decimal_places=2)
    enabled = models.BooleanField()

    def __unicode__(self):
        return self.name

class SpendingItem(models.Model):
    amount = models.DecimalField(max_digits=20, decimal_places=2)
    date = models.DateField()
    category = models.ForeignKey(Category)
    notes = models.CharField(max_length=200)

    def __unicode__(self):
        return self.amount + '@' + self.category.name

